package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.sc.nft.enums.AllocationTypeEnum;
import com.sc.nft.enums.MarketLevelEnum;
import lombok.extern.slf4j.Slf4j;
import com.sc.nft.entity.DaoMoneyPool;
import com.sc.nft.mapper.DaoMoneyPoolMapper;
import  com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * (sc_dao_money_pool)数据DAO
 *
 * @author zxy
 * @since 2023-12-12 14:20:46
 * @description 商户banner
 */
@Slf4j
@Repository
public class DaoMoneyPoolDao extends ServiceImpl<DaoMoneyPoolMapper, DaoMoneyPool> {

    public DaoMoneyPool getByWeekAndType(Long daoId, MarketLevelEnum marketLevel, Integer yearWeek, AllocationTypeEnum type,Boolean settleStatus){
        LambdaQueryWrapper<DaoMoneyPool> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(DaoMoneyPool::getDaoId,daoId);
        wrapper.eq(DaoMoneyPool::getMarketLevel,marketLevel);
        wrapper.eq(DaoMoneyPool::getYearWeek,yearWeek);
        wrapper.eq(DaoMoneyPool::getIsSettle,settleStatus);
        wrapper.eq(DaoMoneyPool::getAllocationType,type);
        return getOne(wrapper);
    }

    public List<DaoMoneyPool> getWaitSettle( String yearWeek, AllocationTypeEnum type){
        LambdaQueryWrapper<DaoMoneyPool> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(DaoMoneyPool::getYearWeek,yearWeek);
        wrapper.eq(DaoMoneyPool::getIsSettle,false);
        wrapper.eq(DaoMoneyPool::getAllocationType,type);
        return list(wrapper);
    }

}